package com.ms.service.module.fish.test;

import java.nio.ByteBuffer;

import com.ms.service.module.fish.message.FishBaseMessage;
import com.ms.service.module.fish.message.FishMsgType;

/**
 * 客户端消息编码
 * @author cuiwm
 */
public class ClientMsgWriter extends FishBaseMessage{
	
    private Object[] params;
    
    public ClientMsgWriter(Integer cmd,Object... params) {
    	this.cmd = cmd;
    	this.params = params;
	}

	@Override
	public void writeBody(ByteBuffer buf) {
		switch (cmd) {
		case FishMsgType.ACTION_100:
			writeString(buf, params[0].toString());
			break;
		case FishMsgType.ACTION_111:
			buf.putInt((int) params[0]);
			buf.put(((Number) params[1]).byteValue());
			break;
		case FishMsgType.ACTION_200:
			buf.putInt((int) params[0]);
			buf.putInt((int) params[1]);
			break;
		case FishMsgType.ACTION_202:
			buf.put(((Number) params[0]).byteValue());
			buf.putInt((int) params[1]);
			break;
		case FishMsgType.ACTION_203:
			buf.put(((Number) params[0]).byteValue());
			break;
		case FishMsgType.ACTION_204:
			buf.putInt((int) params[0]);
			break;

		default:
			break;
		}
	}


}